<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of nansum</title>
  <meta name="keywords" content="nansum">
  <meta name="description" content="NANSUM Sum, ignoring NaNs.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
  <script type="text/javascript">
    if (top.frames.length == 0) { top.location = "../../index.html"; };
  </script>
</head>
<body>
<a name="_top"></a>
<!-- ../menu.html VMT_4.0_dev --><!-- menu.html utils -->
<h1>nansum
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>NANSUM Sum, ignoring NaNs.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function y = nansum(x,dim) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment">NANSUM Sum, ignoring NaNs.
   Y = NANSUM(X) returns the sum of X, treating NaNs as missing values.
   For vector input, Y is the sum of the non-NaN elements in X.  For
   matrix input, Y is a row vector containing the sum of non-NaN elements
   in each column.  For N-D arrays, NANSUM operates along the first
   non-singleton dimension.

   Y = NANSUM(X,DIM) takes the sum along dimension DIM of X.

   See also SUM, NANMEAN, NANVAR, NANSTD, NANMIN, NANMAX, NANMEDIAN.</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
</ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="ADCP_DispCoef.html" class="code" title="function [k,kc,Eyc,Q] = ADCP_DispCoef(beddepth,travdist,vertdepth,downstvel,startDist,endDist,extrp,extend_to_banks,banktype);">ADCP_DispCoef</a>	This program computes the longitudinal dispersion coefficient from ADCP</li><li><a href="ExtractMCS.html" class="code" title="function [y,elev,wse] = ExtractMCS">ExtractMCS</a>	%</li><li><a href="tfile.html" class="code" title="function [A]=tfile(fullName,screenData,ignoreBS);">tfile</a>	tfile reads the data from an RDI ASCII output file and puts the</li></ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function y = nansum(x,dim)</a>
0002 <span class="comment">%NANSUM Sum, ignoring NaNs.</span>
0003 <span class="comment">%   Y = NANSUM(X) returns the sum of X, treating NaNs as missing values.</span>
0004 <span class="comment">%   For vector input, Y is the sum of the non-NaN elements in X.  For</span>
0005 <span class="comment">%   matrix input, Y is a row vector containing the sum of non-NaN elements</span>
0006 <span class="comment">%   in each column.  For N-D arrays, NANSUM operates along the first</span>
0007 <span class="comment">%   non-singleton dimension.</span>
0008 <span class="comment">%</span>
0009 <span class="comment">%   Y = NANSUM(X,DIM) takes the sum along dimension DIM of X.</span>
0010 <span class="comment">%</span>
0011 <span class="comment">%   See also SUM, NANMEAN, NANVAR, NANSTD, NANMIN, NANMAX, NANMEDIAN.</span>
0012 
0013 <span class="comment">%   Copyright 1993-2004 The MathWorks, Inc.</span>
0014 <span class="comment">%   $Revision: 2.10.2.4 $  $Date: 2004/07/28 04:38:44 $</span>
0015 
0016 <span class="comment">% Find NaNs and set them to zero.  Then sum up non-NaNs.  Cols of all NaNs</span>
0017 <span class="comment">% will return zero.</span>
0018 x(isnan(x)) = 0;
0019 <span class="keyword">if</span> nargin == 1 <span class="comment">% let sum figure out which dimension to work along</span>
0020     y = sum(x);
0021 <span class="keyword">else</span>           <span class="comment">% work along the explicitly given dimension</span>
0022     y = sum(x,dim);
0023 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Thu 21-Mar-2013 09:32:01 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2005</address>
</body>
</html>